-- --泛型 for 迭代器
-- local arr1={"one","two","tree",nil,2}

-- for i,v in ipairs(arr1)
-- do
--     print(v)
-- end


--多状态迭代器
arr1={"one","tiwom","1232"}
local function  elementIterator(collection)
    local index=0
    local count=#collection
    return function()
        if index < count
        then
            index=index+1
            return collection[index]

        end
    end
end
for element in elementIterator(arr1)
do
    print(element)
end

--无状态迭代器


